home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BBS Toolkit
/
BBS Toolkit.iso
/
qbbs
/
msgsaver.zip
/
MSGSAVER.C
next >
Wrap
Text File
|
1989-04-05
|
1KB
|
53 lines
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include "qbbsstru.h"
#define MAXMSG 32767
FILE *InfoFile;
info_record InfoBuff;
char InfoName[] = "MSGINFO.BBS",
Error1[] = "MSGINFO.BBS not found\n\n",
Error2[] = "Invalid parameter\n",
StartMsg[] = "MSGSAVER - PD Software by Mark Murphy\n",
Syntax[] = "\nSyntax:\n"
" MSGSAVER [maxmsg]\n"
"\nWhere:\n"
" maxmsg is an integer <= 32767. Default\n"
" value for maxmsg is 32000\n";
char Param[6] = "";
int i, MaxMsg = 32000;
main (int argc, char *argv[])
{
printf (StartMsg);
InfoFile = fopen (InfoName, "rb");
if (InfoFile == NULL) {
printf (Error1);
exit (1);
}
if (argc > 2) {
printf (Error2);
printf (Syntax);
exit (2);
}
if (argc == 2) {
strncpy (Param, argv[1], 5);
Param[5] = NULL;
MaxMsg = strtol (Param, NULL, 10);
if (MaxMsg > MAXMSG || MaxMsg < 0) {
printf (Error2);
printf (Syntax);
exit (2);
}
}
fread (&InfoBuff, sizeof (info_record), 1, InfoFile);
if (InfoBuff.HighMsg > MaxMsg) exit (3);
exit (0);
}